package org.example.cake.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.cake.entity.Cake;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
public interface CakeMapper {
    int deleteByPrimaryKey(Integer cakeid);

    int insert(Cake record);

    int insertSelective(Cake record);

    Cake selectByPrimaryKey(Integer cakeid);

    int updateByPrimaryKeySelective(Cake record);

    int updateByPrimaryKey(Cake record);

    /**
     * 根据分类id查询蛋糕集合
     * @param categoryid 分类id
     * @return 蛋糕集合
     */
    List<Cake> getCakeListByCategoryId(Integer categoryid);

    /**
     * 根据蛋糕id查询蛋糕信息
     * @param cakeid 蛋糕id
     * @return 蛋糕信息
     */
    Cake getCakeById(Integer cakeid);


    /**
     * 查询所有蛋糕
     * @return 蛋糕集合
     */
    List<Cake> getAllCake(@Param("cakename") String cakename, @Param("status") Integer status);

     int updateCakeHou(@Param("cakeId") List<Long> cakeId);
     int updateCakeInfo(@RequestBody Cake cake);
    /**
     * 根据传过来的关键字模糊查询
     * @Date 2025-07-28 谭丽娜
     * @param pattern 蛋糕名字
     * @return
     */
    List<Cake> findByPattern(@Param("pattern") String pattern);

    /**
     * 查询新品蛋糕
     * @return 蛋糕集合
     */
    public List<Cake> selectNewCakeList();

    /**
     * 查询精选蛋糕
     * @return 蛋糕集合
     */
    public List<Cake> selectChoiceCakeList();

    /**
     * 查询所有蛋糕列表
     * @author luojiangjin
     * @return 蛋糕列表
     */
    List<Cake> selectAllCakes();
    /**
     * 查询蛋糕
     * @Date 2025-08-04 谭丽娜
     * @param cakeid
     * @return
     */
    @Select("select * from cake where cakeId=#{cakeid} ")
    Cake getCake(@Param("cakeid") Integer cakeid);
    @Select("select `status` from cake where cakeId=#{cakeid} ")
    Integer ifcakeStatus(@Param("cakeid") Integer cakeid);
}